package com.zzyl.controller.manager;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划管理")
public class NursingPlanController {

    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping(path = "/search")
    @ApiOperation("分页查询护理计划列表")
    public ResponseResult<PageResponse<NursingPlanVo>> findNursingPlanPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        return ResponseResult.success(nursingPlanService.findNursingPlanPage(name, status, pageNum, pageSize));
    }

    @ApiOperation("新增护理计划")
    @PostMapping
    public ResponseResult<Void> addNursingPlan(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.addNursingPlan(nursingPlanDto);
        return ResponseResult.success();
    }

    @ApiOperation("根据id查询护理计划")
    @GetMapping("/{id}")
    public ResponseResult<NursingPlanVo> findNursingPlanById(@PathVariable Long id) {
        return ResponseResult.success(nursingPlanService.findNursingPlanById(id));
    }

    @ApiOperation("修改护理计划")
    @PutMapping
    public ResponseResult<Void> updateNursingPlan(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.updateNursingPlan(nursingPlanDto);
        return ResponseResult.success();
    }

    @ApiOperation("删除护理计划")
    @DeleteMapping("/{id}")
    public ResponseResult<Void> deleteNursingPlan(@PathVariable Long id) {
        nursingPlanService.deleteNursingPlan(id);
        return ResponseResult.success();
    }

    @ApiOperation("启用/禁用护理计划")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult<Void> updateNursingPlanByStatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingPlanService.updateNursingPlanByStatus(id, status);
        return ResponseResult.success();
    }

    @ApiOperation("查询所有护理计划")
    @GetMapping
    public ResponseResult<List<NursingPlanVo>> findAllNursingPlan() {
        return ResponseResult.success(nursingPlanService.findAllNursingPlan());
    }

}
